from pyquery import PyQuery as pq
from selenium import webdriver
from urllib.parse import quote

keyword = input("输入查找关键词：")
url = "https://so.csdn.net/so/search?q=" + quote(keyword)
print(url)
browser = webdriver.Chrome()
browser.get(url)
for i in range(3000):
    browser.execute_script("window.scrollBy(0,500)")
doc = pq(browser.page_source)
ass = doc('a').items()
skip = 13
al = []
for a in ass:
    text = a.text()
    href = a.attr.href
    if href.startswith("https://"):
        al.append(href + ", " + text)
        if href.startswith("https://so.csdn.net/so/search?q="):
            break
for i in al[14:]:
    print(i)
browser.close()